

//-------------    setTimeout 函数   
    //    setTimeout(() => {
    //         alert("Ary you going to start at this boring page forever?(with js file)")
    //         console.log("游戏开始")

    //         var guess = prompt("猜个数，（0~6）");
    //         console.log("当前猜的数字是：", guess);

    //         testfun("测试函数调用1");
    //         testfun();
    //         testfun("测试函数调用2-1", "cansh 2-2");

    //     }, 1000);

//-----------------语句语法
function testfun(paramA){
    console.log("receive msg:" + paramA);
    var count = 0;
    while (++count <= 3) {
        /* var*/ currMsg = "counter to" + count;
        console.log(currMsg);
    }
}

//testfun("调用试试");
//console.log(currMsg);

//testfun("object 类型测试");

//-----------------object对象
let person = {name: "x",
    changeAge: function(ageNew){
        this.age += 1;
    },
    GetCurrAge: function(){return this.age;},
    //age : 36, //正常运行
};

function TestShowPerson()
{
    console.log(person.GetCurrAge());// undefined

    person.age =36; //这样也可以
    person.changeAge(person.GetCurrAge() + 1);
    console.log(person);
    //输出：
    // {
    //     "name": "x",
    //     "age": 37
    // }
}
//TestShowPerson();


//---------Dom一些使用学习
function OperatorDom() {
    let h1list = document.getElementsByTagName("h1");
    console.log(h1list);
    console.log(h1list[0]);
    h1list[0].append("_稍作修改");
    //document.get
}
//setTimeout(OperatorDom, 1000);
//OperatorDom();

//---------测试类型 null undefined等
function TestNullUndefinedType()
{
    let var1 = 1;
    let var2;
    let var3 = undefined;
    let var4 = null;
    console.log("type of var1:" + typeof var1 +
        ", var2:"+ typeof var2 +
        ", var3:"+ typeof var3 + 
        ", var4:"+ typeof var4);
        //code.js:75 type of var1:number, var2:undefined, var3:undefined, var4:object
    var1 = undefined;
    console.log("type of var1:" + typeof var1 +
        ", var2:"+ typeof var2 +
        ", var3:"+ typeof var3 + 
        ", var4:"+ typeof var4);
        //code.js:80 type of var1:undefined, var2:undefined, var3:undefined, var4:object
}

//---------测试类型 null undefined等
function TestNaN()
{
    //let var1 = 1/0;//Infinity
    let var1 = 0/0; //NAN
    let var2 = NaN;
    console.log(
        "type of var1:" + typeof var1 + " value is:" + var1 +
        ", type of var2:"+ typeof var2 + " value is:" + var2);
        //两个类型都是 number，值都是NAN
        console.log("string to isNaN fun return:" + isNaN("test string"));
}

function TestCompare()
{
    console.log("99" == 99);//true "99">99
    console.log("99abc" == 99);//false "abc">NaN

    console.log(undefined == null); //true 这个就硬记吧

    console.log(1 == true);//true true>1    数字只有1 == true
    console.log(0 == true);//false true>1
    console.log(2 == true);//false true>1

    console.log("compare with false")
    console.log(1 == false);//false false>0    数字只有1 == true
    console.log(0 == false);//true false>0
    console.log(2 == false);//false false>0

    console.log(1 == "");//false "">0
    console.log(0 == "");//true "">0
    console.log(false == "");//true false>0, "">0
    console.log(false == "0");//true false>0, "0">0

    let strObj = "abc";
    let obj;
    let numObj = 3;
}

//window.onload = TestCompare;

let varToMuti = "test";
console.log(varToMuti);//输出 test
varToMuti = 333;
console.log(varToMuti); //正常输出 333


